//
//  YSGHomeDepartmentItemCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/11/13.
//  Copyright © 2020 QDSG. All rights reserved.
//

import UIKit

class YSGHomeDepartmentItemCell: UICollectionViewCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        makeUI()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        makeUI()
    }
    
    func makeUI() {
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        layer.cornerRadius = 8
        clipsToBounds = true
    }
    
    func setSelected(_ isSelected: Bool) {
        contentView.backgroundColor = isSelected ? .mainLight : .white
    }
    
    func configure(with vm: YSGDepartmentItemViewModel, isHome: Bool = true) {
        setSelected(false)
        if isHome {
            bgImageView.kf.setImage(with: URL(string: vm.model.url ?? ""))
        }
        nameLabel.text = vm.model.name
    }
    
    @IBOutlet private weak var bgImageView: UIImageView! {
        didSet {
            bgImageView.contentMode = .scaleAspectFill
        }
    }
    
    @IBOutlet private weak var nameLabel: UILabel! {
        didSet {
            nameLabel.textColor = .textDark
            nameLabel.font = .regular_14
        }
    }
    
}
